package com.panasonic.web.domain.cms;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.panasonic.common.annotation.Excel;
import com.panasonic.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;


/**
 * 考试信息对象 cms_exam
 *
 * @author lwf
 * @date 2021-11-16
 */
@Data
public class CmsExam extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    private Long id;

    private Long categoryId;

    @NotNull(message = "名称不能为空")
    /** 名称 */
    @Excel(name = "名称")
    private String name;

    /**
     * 状态 0 正常 1 暂停
     */
    @Excel(name = "状态 0 正常 1 暂停")
    private Long status;

    @NotNull(message = "开始时间不能为空")
    /** 开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;
    @NotNull(message = "结束时间不能为空")
    /** 结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date endDate;
    @NotNull(message = "时长不能为空")
    /** 时长 分钟 */
    @Excel(name = "时长 分钟")
    private Integer duration;
    @NotNull(message = "选择题分数不能为空")
    /** 选择题分数 */
    @Excel(name = "选择题分数")
    private Integer chooseScore;
    @NotNull(message = "填空题分数不能为空")
    /** 填空题分数 */
    @Excel(name = "填空题分数")
    private Integer fillInTheBlankScore;
    @NotNull(message = "其他分数不能为空")
    /** 其他分数 */
    @Excel(name = "其他分数")
    private Integer otherScore;

    /**
     * 总分数
     */
    @Excel(name = "总分数")
    private Integer totalScore;

    /**
     * 次数
     */
    private  Integer frequency;
    /**
     *  考试状态
     */
    private Integer examStatus;
    /**
     * 分数
     */
    private Integer score;


    private Long panId;
    /**
     * 试卷问题信息
     */
    private List<CmsExamQuestion> cmsExamQuestionList;

    public void sumTotalScore() {
        this.setTotalScore(this.getChooseScore() + this.getFillInTheBlankScore() + this.getTotalScore());
    }
}
